package nodeList;


import java.util.LinkedList;
import java.util.Queue;

/**
 * 队列模拟栈
 * @author le
 */
public class QueueToStack
{
    public static void main(String[] args)
    {
        Queue<Integer> queue = new LinkedList<>();

        for (int i = 0; i < 5; i++)
        {
            queue.offer(i);
            int len = queue.size();
            int j = 0;
            while(j < len -1){
                queue.offer(queue.poll());
                j++;
            }
        }
        for (int i = 0; i < 5; i++)
        {
            System.out.println(queue.poll());
        }
    }

}
